home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12628 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  49 lines

  1. Newsgroups: comp.lang.c++
  2. Path: news.sprintlink.net!mv!usenet
  3. From: ENGR@GSSI.MV.COM (Michael Furman)
  4. Subject: Re: Help me please
  5. Message-ID: <DoL71M.32H@mv.mv.com>
  6. Mime-Version: 1.0
  7. Content-Type: Text/Plain; charset=US-ASCII
  8. Organization: GSSI
  9. Date: Wed, 20 Mar 1996 22:12:58 GMT
  10. References: <9MGBMHAUirSxEwbi@waichung.demon.co.uk>
  11. X-Newsreader: WinVN 0.99.7
  12. X-Nntp-Posting-Host: gssi.mv.com
  13.  
  14. In article <9MGBMHAUirSxEwbi@waichung.demon.co.uk>, kyn@waichung.demon.co.uk 
  15. says...
  16. >
  17. >I require help in constructing a binary search tree in c++, as i am 
  18. >relatively new to the language i am not sure how to go about
  19. >implementing it. 
  20. > Do i construct a class called btree or do i use the following:-
  21. >
  22. > struct node 
  23. >  {
  24. >   data  d;
  25. >   struct node  *left;
  26. >   struct node  *right;
  27. >  }
  28.  
  29. You just constructed class "node"! "struct" and "class" keywords in C++ are
  30. almost the same: "struct" is an equivalent of the class with "public:"
  31. placed before the first member.
  32.  
  33. You can translate your pascal code, but it will be "C" - not C++ (but you can
  34. use C++ compiler because C is "almost" a subset of C++).
  35.  
  36. If you want to use C++ features - first look for member functions and static
  37. member functions. Also for inheritance, if you want use your tree
  38. functionality for any data objects.
  39.  
  40. -- 
  41. <<< If you received it by E-mail: it is a copy of post to the newsgroup >>>
  42. ---------------------------------------------------------------
  43. Michael Furman,                       (603)893-1109
  44. Geophysical Survey Systems, Inc.  fax:(603)889-3984
  45. 13 Klein Drive - P.O. Box 97          engr@gssi.mv.com 
  46. North Salem, NH 03073-0097            71543.1334@compuserve.com
  47. ---------------------------------------------------------------
  48.  
  49.